package com.yunshan.mp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yunshan.common.annotation.Log;
import com.yunshan.common.core.controller.BaseController;
import com.yunshan.common.core.domain.AjaxResult;
import com.yunshan.common.enums.BusinessType;
import com.yunshan.mp.domain.MpIndexActivityReview;
import com.yunshan.mp.service.IMpIndexActivityReviewService;
import com.yunshan.common.utils.poi.ExcelUtil;
import com.yunshan.common.core.page.TableDataInfo;

/**
 * 活动回顾Controller
 * 
 * @author yunshan
 * @date 2025-01-20
 */
@Api(tags = "活动回顾")
@RestController
@RequestMapping("/mp/activityReview")
public class MpIndexActivityReviewController extends BaseController
{
    @Autowired
    private IMpIndexActivityReviewService mpIndexActivityReviewService;

    /**
     * 查询活动回顾列表
     */
    @ApiOperation("查询活动回顾列表")
    @GetMapping("/list")
    public TableDataInfo list(MpIndexActivityReview mpIndexActivityReview)
    {
        startPage();
        List<MpIndexActivityReview> list = mpIndexActivityReviewService.selectMpIndexActivityReviewList(mpIndexActivityReview);
        return getDataTable(list);
    }

    /**
     * 导出活动回顾列表
     */
    @ApiOperation("导出活动回顾列表")
    @Log(title = "活动回顾", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MpIndexActivityReview mpIndexActivityReview)
    {
        List<MpIndexActivityReview> list = mpIndexActivityReviewService.selectMpIndexActivityReviewList(mpIndexActivityReview);
        ExcelUtil<MpIndexActivityReview> util = new ExcelUtil<MpIndexActivityReview>(MpIndexActivityReview.class);
        util.exportExcel(response, list, "活动回顾数据");
    }

    /**
     * 获取活动回顾详细信息
     */
    @ApiOperation("获取活动回顾详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(mpIndexActivityReviewService.selectMpIndexActivityReviewById(id));
    }

    /**
     * 新增活动回顾
     */
    @ApiOperation("新增活动回顾")
    @Log(title = "活动回顾", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MpIndexActivityReview mpIndexActivityReview)
    {
        return toAjax(mpIndexActivityReviewService.insertMpIndexActivityReview(mpIndexActivityReview));
    }

    /**
     * 修改活动回顾
     */
    @ApiOperation("修改活动回顾")
    @Log(title = "活动回顾", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MpIndexActivityReview mpIndexActivityReview)
    {
        if (mpIndexActivityReview.getId() == null){
            return toAjax(mpIndexActivityReviewService.insertMpIndexActivityReview(mpIndexActivityReview));
        }

        return toAjax(mpIndexActivityReviewService.updateMpIndexActivityReview(mpIndexActivityReview));
    }

    /**
     * 删除活动回顾
     */
    @ApiOperation("删除活动回顾")
    @Log(title = "活动回顾", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mpIndexActivityReviewService.deleteMpIndexActivityReviewByIds(ids));
    }

    /**
     * 查询活动回顾
     */
    @ApiOperation("查询活动回顾")
    @GetMapping("/query")
    public AjaxResult query(MpIndexActivityReview mpIndexActivityReview)
    {
        mpIndexActivityReview.setStatus(0);
        mpIndexActivityReview.setIsDeleted(0);
        MpIndexActivityReview mpIndexActivity = new MpIndexActivityReview();
        List<MpIndexActivityReview> list = mpIndexActivityReviewService.selectMpIndexActivityReviewList(mpIndexActivityReview);
        if (list.size() > 0){
            mpIndexActivity = list.get(0);
        }

        return success(mpIndexActivity);
    }
}
